<?php
/*
**酷秀验证消费通知
**date 2015-12-07
**user by pzp
*/
include('/var/www/html/new/d/module/api/function.class.php');

$orderid = $_REQUEST['orderid'];
$verifycode = $_REQUEST['verifycode'];
$consume_num = $_REQUEST['consume_num'];
$timestamp = date('Y-m-d H:i:s' , $_REQUEST['timestamp']);
$sign = $_REQUEST['sign'];

if (!class_exists("go_sql")){
	include("/var/www/html/new/conf/le.je");
	$le=new go_sql();
	$le->connect();
}

$PFT_infunction = new AllFunction();
$PFT_infunction->logfile('16|'.json_encode($_REQUEST),'checkNote');

$sel = "select pftOrder,apiOrder from all_api_order where tempOrder='$orderid' and coopB=16 and apiCode='$verifycode' limit 1";
$GLOBALS['le']->query($sel);
if(!$GLOBALS['le']->fetch_assoc()){
	$response = array(
		'code'		=> '-8',
		'message'	=> '无订单信息',
	);
	exit(json_encode($response));
}

$pftOrder = $GLOBALS['le']->f('pftOrder');
$apiOrder = $GLOBALS['le']->f('apiOrder');
$pft_order_xml = $PFT_infunction->Select_PFTorder($pftOrder);
$UUsalerid  = (string)$pft_order_xml->Rec->UUsalerid;
$UUcode  = (string)$pft_order_xml->Rec->UUcode;
$chkIns = 499;
if((int)$pft_order_xml->Rec->UUstatus==2) $chkIns = 498;
$r = $PFT_infunction->Unified_Check_IN($UUsalerid,$UUcode,$timestamp,$chkIns);
if($r == 100){
	$selorder = "update all_api_order  set oStatus=1 where pftOrder='$pftOrder' limit 1";
	$GLOBALS['le']->query($selorder);
	$PFT_infunction->logfile('16|'.$pftOrder."|".$orderid."|".$apiOrder."|".$r,"check_s");	
	$response = array(
		'code'		=> '0',
		'message'	=> '更新状态成功',
	);
	exit(json_encode($response));
	
}else{
	$PFT_infunction->logfile('16|'.$pftOrder."|".$orderid."|".$apiOrder."|".$r,"check_f");
	$response = array(
		'code'		=> '1',
		'message'	=> $r,
	);
	exit(json_encode($response));
}


